package com.ruoyi.web.controller.system;

import java.util.List;


import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.IJingyingcontextService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Jingyingcontext;

import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 经营服务内容 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/jingyingcontext")
public class JingyingcontextController extends BaseController
{
    private String prefix = "system/jingyingcontext";
	
	@Autowired
	private IJingyingcontextService jingyingcontextService;
	
	@RequiresPermissions("system:jingyingcontext:view")
	@GetMapping()
	public String jingyingcontext()
	{
	    return prefix + "/jingyingcontext";
	}
	
	/**
	 * 查询经营服务内容列表
	 */
	@RequiresPermissions("system:jingyingcontext:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Jingyingcontext jingyingcontext)
	{
		startPage();
        List<Jingyingcontext> list = jingyingcontextService.selectJingyingcontextList(jingyingcontext);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出经营服务内容列表
	 */
	@RequiresPermissions("system:jingyingcontext:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Jingyingcontext jingyingcontext)
    {
    	List<Jingyingcontext> list = jingyingcontextService.selectJingyingcontextList(jingyingcontext);
        ExcelUtil<Jingyingcontext> util = new ExcelUtil<Jingyingcontext>(Jingyingcontext.class);
        return util.exportExcel(list, "jingyingcontext");
    }
	
	/**
	 * 新增经营服务内容
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存经营服务内容
	 */
	@RequiresPermissions("system:jingyingcontext:add")
	@Log(title = "经营服务内容", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Jingyingcontext jingyingcontext)
	{
		SysUser sysUser = getSysUser();
		jingyingcontext.setShanghuId(sysUser.getUserId());
		return toAjax(jingyingcontextService.insertJingyingcontext(jingyingcontext));
	}

	/**
	 * 修改经营服务内容
	 */
	@GetMapping("/edit/{jingyingcontextId}")
	public String edit(@PathVariable("jingyingcontextId") Integer jingyingcontextId, ModelMap mmap)
	{
		Jingyingcontext jingyingcontext = jingyingcontextService.selectJingyingcontextById(jingyingcontextId);
		mmap.put("jingyingcontext", jingyingcontext);
	    return prefix + "/edit";
	}

	/**
	 * 修改经营服务内容
	 */
	@GetMapping("/onloadZiliao/{jingyingcontextId}")
	public String onloadZiliao(@PathVariable("jingyingcontextId") Integer jingyingcontextId, ModelMap mmap)
	{
		Jingyingcontext jingyingcontext = jingyingcontextService.selectJingyingcontextById(jingyingcontextId);
		mmap.put("jingyingcontext", jingyingcontext);
		return prefix + "/onload";
	}
	
	/**
	 * 修改保存经营服务内容
	 */
	@RequiresPermissions("system:jingyingcontext:edit")
	@Log(title = "经营服务内容", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Jingyingcontext jingyingcontext)
	{		
		return toAjax(jingyingcontextService.updateJingyingcontext(jingyingcontext));
	}
	
	/**
	 * 删除经营服务内容
	 */
	@RequiresPermissions("system:jingyingcontext:remove")
	@Log(title = "经营服务内容", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jingyingcontextService.deleteJingyingcontextByIds(ids));
	}
	
}
